{include file='admin/header.html'}

<!-- 搜索框 -->
<div class="layui-form">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">{$tran.article} ID</label>
            <div class="layui-input-block">
                <input type="number" name="article_id" value="" placeholder="{$tran.input}" class="layui-input">
            </div>
        </div>
        {if $action=='index'}
        <div class="layui-inline">
            <label class="layui-form-label">{$tran.comment_author}</label>
            <div class="layui-input-block">
                <input type="text" name="author" value="" placeholder="{$tran.input}" class="layui-input">
            </div>
        </div>
        {/if}
        <div class="layui-inline">
            <label class="layui-form-label">{$tran.comment_content}</label>
            <div class="layui-input-block">
                <input type="text" name="comment" value="" placeholder="{$tran.input}" class="layui-input">
            </div>
        </div>
        {if $action=='index'}
        <div class="layui-inline">
            <label class="layui-form-label">{$tran.status}</label>
            <div class="layui-input-block">
                <select name="status">
                    <option value="">{$tran.choose}</option>
                    <option value="0">{$tran.normal}</option>
                    <option value="1">{$tran.pending}</option>
                    <option value="2">{$tran.spam}</option>
                </select>
            </div>
        </div>
        {/if}
        <div class="layui-inline">
            <label class="layui-form-label">{$tran.date}</label>
            <div class="layui-input-inline" style="width: 100px;">
                <input type="text" name="start" placeholder="yyyy-MM-dd" class="layui-input date">
            </div>
            <div class="layui-form-mid">-</div>
            <div class="layui-input-inline" style="width: 100px;">
                <input type="text" name="end" placeholder="yyyy-MM-dd" class="layui-input date">
            </div>
        </div>
        <div class="layui-inline">
            <button type="submit" lay-submit lay-filter="search"
                class="layui-btn layui-icon layui-icon-search"></button>
        </div>
    </div>
</div>

<!-- 数据表格 -->
<table id="dataTable" lay-filter="dataTable"></table>

<!-- 头工具栏 -->
<script type="text/html" id="toolbar">
    <div class="layui-btn-group">
        <button class="layui-btn layui-btn-sm layui-icon layui-icon-delete" title="{$tran.delall}" lay-event="delAll"></button>
        <button class="layui-btn layui-btn-sm layui-icon layui-icon-refresh" title="{$tran.refresh}" lay-event="refresh"></button>
    </div>
    {if $action=='index'}
    <div class="layui-btn-group">
        <button class="layui-btn layui-btn-sm" title="{$tran.pending}" lay-event="pending">{$tran.pending}</button>
        <button class="layui-btn layui-btn-sm" title="{$tran.approve}" lay-event="passed">{$tran.approve}</button>
        <button class="layui-btn layui-btn-sm" title="{$tran.rubbish}" lay-event="spam">{$tran.spam}</button>
    </div>
    {/if}
</script>

<!-- dataTable render -->
<script>
    var site_url = '//{$smarty.server.SERVER_NAME}' + (('{$smarty.server.SERVER_PORT}' == '80' || '{$smarty.server.SERVER_PORT}' == '443') ? '' : ':{$smarty.server.SERVER_PORT}');
    var render = {
        elem: '#dataTable',
        toolbar: '#toolbar',
        defaultToolbar: ['filter', 'exports', 'print'],
        cellMinWidth: 80,
        height: 'full',
        where: { search: '' }, //搜索
        title: '{$tran.comment_list}', //数据表格标题
        page: true, //开启分页
        url: site_url + '/{$lang}/admin/comment/{$action}.html',
        cols: [[
            { type: 'checkbox', fixed: 'left' },
            { field: 'id', title: 'ID', sort: true, width: 80 },
            {
                field: 'author', title: '{$tran.author}', sort: true, templet: function (d) {
                    return d.action == 'robot' ? '{$tran.rebot}' : d.author;
                }
            },
            { field: 'tree_comment', title: '{$tran.comment_content}' },
            {
                field: 'article_id', title: '{$tran.comment_article}', sort: true, templet: function (d) {
                    return '<a href="' + d.article_link + '" title="' + d.article_title + '" target="_blank">' + d.article_title + '</a>';
                }
            },
            { field: 'sort', title: '{$tran.sort}', sort: true },
            {
                field: 'status', title: '{$tran.status}', sort: true, width: 90, templet: function (d) {
                    if (d.status == 0) return '<span style="color:green">{$tran.normal}</span>';
                    else if (d.status == 1) return '<span style="color:red">{$tran.pending}</span>';
                    else if (d.status == 2) return '<span style="color:grey">{$tran.spam}</span>';
                    else if (d.status == 3) return '<span style="color:grey;text-decoration:line-through;">{$tran.robot_comment}</span>';
                }
            },
            { field: 'time', title: '{$tran.time}', sort: true },
            {
                title: '{$tran.option}', align: 'center', width: 125, templet: function (d) {
                    return (d.action == 'robot' ? '' : '<button class="layui-btn layui-btn-primary layui-btn-xs layui-icon layui-icon-at'+ (d.pid != 0 ? ' layui-btn-disabled' : '') +'" title="{$tran.reply}"' + (d.pid == 0 ? ' lay-event="replay"' : '') + '></button>' +
                        '<button class="layui-btn layui-btn-normal layui-btn-xs layui-icon layui-icon-edit" title="{$tran.edit}" lay-event="edit"></button>') +
                        '<button class="layui-btn layui-btn-danger layui-btn-xs layui-icon layui-icon-delete" title="{$tran.delete}" lay-event="del2"></button>';
                }
            }
        ]]
    }
</script>

{include file='admin/inc/dataTable.html'}

{include file='admin/footer.html'}